package com.ycy.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ycy.topapi.TopApiUtil;
import com.ycy.topapi.TopResult;

@SuppressWarnings("serial")
public class ConvertServlet extends HttpServlet{
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException{
		String numIids = req.getParameter("i");
		String nick = req.getParameter("n");
		nick = new String(nick.getBytes("ISO-8859-1"), "UTF-8");
		// TODO check token

		// numIids = "4252939061";
		// nick = "karin婷";
		if (numIids == null || nick == null) {
			return;
		}
		resp.setContentType("text/plain");
		resp.setCharacterEncoding("UTF-8");

		TopResult res = TopApiUtil.tbkConvert(numIids, nick);
		System.out.println(res+":"+res.getJson());
		resp.getWriter().println(res.getJson());
	}
}
